package cn.jlonely.xyhx.app.mapper;


import cn.jlonely.xyhx.pojo.Review;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface AppReviewMapper {

    /**
     * 获取某个活动排名信息
     * @param id
     * @return
     */
    List<Review> getReviewInfo(Integer id);


    /**
     * 参加活动
     * @param review
     */
    @Insert("insert into review_table(topic,cover_image,introduce,user_id,ranking_id) values(#{topic},#{coverImage},#{introduce},#{userId},#{rankingId})")
    void creatReview(Review review);


    /**
     * 判断是否已经参加活动
     * @param rankingId
     * @param userId
     * @return
     */
    @Select("SELECT COUNT(*) FROM review_table WHERE ranking_id = #{rankingId} AND user_id = #{userId}")
    boolean selectById(@Param("rankingId") Integer rankingId, @Param("userId") Integer userId);



    /**
     * 给活动投票数加1
     */
    @Update("UPDATE review_table SET number = number + 1 WHERE judge_id = #{judgeId}")
    void creatNumber(Integer judgeId);
}
